# -*- coding: utf-8 -*-

import json
from urllib.request import urlopen


def get_country(ip_address):
    api = 'http://freegeoip.net/json/'
    response = urlopen(api+ip_address).read().decode('utf-8')
    response_json = json.loads(response)
    return response_json.get('country_code')


print(get_country('58.246.245.18'))
